package com.tanhua.interceptor;


import model.domain.User;

public class UserHolder {
    private static ThreadLocal<User> threadLocal = new ThreadLocal<>();

    public static void set(User user) {
        threadLocal.set(user);
    }

    public static User get() {
        return threadLocal.get();
    }

    public static String getMobile() {
        return threadLocal.get() == null ? null : threadLocal.get().getMobile();
    }

    public static Long getUserId() {
        return threadLocal.get() == null ? null : threadLocal.get().getId();
    }

    public static void remove() {
        threadLocal.remove();
    }
}
